package h0724;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 数据单元的变化替换
 * @date 2024/7/24 20:50
 */
public class ReplacementOfChangesInDataUnits {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(",");

        Map<String, String> map = new LinkedHashMap<>();
        char c = 'A';
        for (int i = 0; i < s.length; i++) {
            map.put("<" +(char)(c + i) + ">", s[i]);
        }
        //TODO 暂未处理非法情况
        Set<String> keys = map.keySet();
        Pattern p = Pattern.compile("<[A-Z]>");

        List<String> res=new ArrayList<>();
        for (String value : map.values()) {
            while (true){
                Matcher matcher = p.matcher(value);
                if (matcher.find()) {
                    String temp = matcher.group();
                    if (keys.contains(temp)){
                        value=value.replace(temp,map.get(temp));
                    }
                }else {
                    //存储结果
                    res.add(value);
                    break;
                }
            }
        }
        StringJoiner joiner=new StringJoiner(" ");
        for (String re : res) {
            joiner.add(re);
        }
        System.out.println(joiner);
    }
}
